const {
  $util,
} = getApp();
Page({
  data: {
  },
  onLoad(opts) {
    this.setData(opts);
  },
  onShow() {
    this.loadDetail();
  },
  loadDetail() {
    $util.request({
      url: 'entry/wxapp/partyman.investigate.gettaskdetail',
      data: {
        id: this.data.id,
        version: 1,
      },
      success: (res) => {
        this.setData(res.data);
        res.data && res.data.title && wx.setNavigationBarTitle({
          title: res.data.title,
        });
      },
    });
  },
  goReport() {
    const { id, idx, status, times } = this.data;
    if (Number(status) === 4) {
      wx.navigateTo({
        url: `/ws_party_const/pages/investigate/list?id=${id}`,
      });
    } else {
      const currentTime = new Date().getTime();
      if (currentTime < Number(times) * 1000) {
        wx.showToast({
          title: '未到考察时间！',
          icon: 'none',
        });
        return; 
      }
      wx.navigateTo({
        url: `/ws_party_const/pages/investigate/report?id=${id}&status=${status}&idx=${idx}`,
      });
    }
  },
});